all: telnet

#include ./MCONFIG
BINDIR=/usr/bin
SBINDIR=/usr/sbin
MANDIR=/usr/man
BINMODE=755
DAEMONMODE=755
MANMODE=644
PREFIX=/usr
EXECPREFIX=/usr
INSTALLROOT=
CC=gcc
CXX=g++
CFLAGS=-g -Wall -Wno-trigraphs
CXXFLAGS=-g -fno-rtti -fno-exceptions -Wall -Wno-trigraphs
LDFLAGS=
LIBS=-lutil -lutil
LIBTERMCAP=-lncurses
USE_GLIBC=1

#include ./MRULES
%.o: %.c
	$(CC) $(CFLAGS) $< -c
%.o: %.cpp
	$(CXX) $(CXXFLAGS) $< -c


#CXXFLAGS:=$(patsubst -O2, -g, $(CXXFLAGS))

# -DAUTHENTICATE
CXXFLAGS += -DUSE_TERMIO -DKLUDGELINEMODE
LIBS = $(LIBTERMCAP)

SRCS = commands.cpp main.cpp network.cpp ring.cpp sys_bsd.cpp telnet.cpp \
	terminal.cpp utilities.cpp genget.cpp environ.cpp netlink.cpp

OBJS = $(patsubst %.cpp, %.o, $(SRCS))

telnet: $(OBJS)
	$(CXX) $(LDFLAGS) $^ $(LIBS) -o $@

include depend.mk
depend:
	$(CXX) $(CXXFLAGS) -MM $(SRCS) >depend.mk

install: telnet
	echo install -m$(BINMODE) telnet $(INSTALLROOT)$(BINDIR)

clean:
	rm -f *.o telnet

